function fn(){
	class Banner{
		constructor(){
			this.left = document.querySelector(".left");
			this.right = document.querySelector(".right");
			this.child = document.querySelectorAll(".imgbox a");
			this.list = document.querySelector(".list");
			this.box = document.querySelector(".banner");
			// 假设点击的是右安钮
			// 要进来的
			this.iNow = 0;
			// 要走的
			this.iPrev = this.child.length - 1;
		}
		init(){
			var that = this;
			this.left.addEventListener("click",function(){
				that.changeIndex(1);
			})
			this.right.addEventListener("click",function(){
				that.changeIndex(-1);
			})
			// L3.事件委托绑定事件
			this.list.onclick = function(eve){
				var e = eve || window.event;
				var tar = e.target || e.srcElement;
				if(tar.tagName == "SPAN"){
					// L4.触发事件时，执行改变索引，同时将当前点击的span传入
					that.listChangeIndex(tar);
				}
			}
		}
		
		
		changeIndex(direct){
			if(direct == 1){
				if(this.iNow == 0){
					// 当点击左按钮，到第0张时，再点，设置成最后一张
					this.iNow = this.child.length-1;
					// 同时第0张走了
					this.iPrev = 0;
				}else{
					// 默认情况下，进来的索引在减小
					this.iNow--;
					// 要走的索引永远是进来的索引+1
			this.iPrev = this.iNow + 1;		
				}
			}else{
				if(this.iNow == this.child.length-1){
					// 当点击右安钮，到最后一张时，再点，设置成第0张
					this.iNow = 0;
					// 同时，最后一张走了
					this.iPrev = this.child.length-1;
				}else{
					// 默认情况下，进来的索引在增加
					this.iNow++;
					// 要走的索引永远是进来的索引-1
					this.iPrev = this.iNow - 1;
				}
			}
			// console.log(this.iPrev,this.iNow);
			// 根据索引开始运动
			this.move(direct);
		}
		move(direct){
			// 根据左右按钮传入的状态：左1，右-1，利用乘法，改变不同按钮的方向问题
			
				this.child[this.iPrev].style.left = 0;
				move(this.child[this.iPrev],{left:this.child[0].offsetWidth * direct});
				
				this.child[this.iNow].style.left = -this.child[0].offsetWidth * direct + "px";
				move(this.child[this.iNow],{left:0});
			
				this.setActive();
		}
		createList(){
			// L1.创建对应图片数量的span同时编号
			var str = ``;
			for(var i = 0;i<this.child.length;i++){
				str += `<span index='${i}'></span>`;
			}
			this.list.innerHTML = str;
			// L2.设置默认的当前项
			this.setActive();
		}
		 setActive(){
			for(var i=0;i<this.list.children.length;i++){
				this.list.children[i].className = "";
			}
			this.list.children[this.iNow].className = "active";
		        }
		listChangeIndex(tar){
			// L5.确定要走的索引和要进来的索引
			// this.iNow  要走的
			// 拿到点击的span的编号  要进来的
			var index = parseInt(tar.getAttribute("index"));
			
			// L6-1.判断方向
			if(index > this.iNow){
				// L7-1.向左运动
				this.listMove(1,index);
			}
			// L6-2.判断方向
			if(index < this.iNow){
				// L7-2.向右运动
				this.listMove(-1,index);
			}
			// L8.将当前点击的索引设置成下一次要走的索引
			this.iNow = index;
			// L9.根据修改之后的索引，设置当前项
			this.setActive();
		}
		listMove(direct,index){
			// this.iNow走
			this.child[this.iNow].style.left = 0;
			move(this.child[this.iNow],{left:-1000 * direct})
			// index进来
			this.child[index].style.left = 1000 * direct + "px";
			move(this.child[index],{left:0});
		}
		autoPlay(){
			var t = setInterval(()=>{
				this.changeIndex(-1);
			},2000)
			this.box.onmouseover = function(){
				clearInterval(t);
			}
			var that = this;
			this.box.onmouseout = function(){
				t = setInterval(()=>{
					that.changeIndex(-1);
				},5000)
			}
		}
	}
			
	var b = new Banner();
	b.init();
	b.createList();		
	b.autoPlay()			
}

function index(){
	class Index{
	        constructor(){
	            this.login = document.querySelector(".banner-r");
	            this.welcome = document.querySelector(".banner-rlogin");
				this.resig = document.querySelector(".resig");
	            this.uName = document.getElementById("userName")
				this.Name = document.getElementById("user")
				this.logout1 = document.querySelector(".logout1");
				this.logout2 = document.querySelector(".logout2");
	            // 对于需要验证是否登录的页面来说，应该立即获取是否登录的信息
	            this.init();
	        }
	        init(){
	            // 获取之后，简单处理数据
	            this.m = sessionStorage.getItem("userMsg");
	            this.m = this.m ? JSON.parse(this.m) : {};
	            // 如果有登录成功后的信息
	            if(this.m.user){
	                // 显示登录的用户名
	                this.uName.innerHTML = this.m.user;
					this.Name.innerHTML = this.m.user;
	                // 显示欢迎信息
	                this.login.style.display = "none";
					this.logout1.style.display = "none";
					this.logout2.style.display = "block";
					this.resig.style.display = "none";
	                // 隐藏登录注册操作
	                this.welcome.style.display = "block";
					this.welcome.style.color="red";
	            }
	        }
	    }
	    new Index;

}
<<<<<<< HEAD

function floor(){
	$(".floor").children("li").click(function(){
	    $("html").animate({
	        scrollTop:$(".floor1").eq($(this).index()).offset().top,
	    })
	})
}
=======
>>>>>>> 5d0a21b06dc39f26b412b2b946e3b19ba3adfcec
